import axios from 'axios'
import type {AxiosRequestConfig, AxiosResponse} from 'axios'

/**
 * @author: ares
 * @date: 2023/3/31 11:12
 * @description: 发送get请求
 * @param {string}url
 * @param {object}config
 */
export function httpGet(url: string, config?: AxiosRequestConfig<{data: any}>): Promise<void | AxiosResponse<any, any>>{
    return axios.get(url, config).catch(error => {
        console.error(`get请求${url}时发生错误`, error.message)
    })
}


/**
 * @author: ares
 * @date: 2023/3/31 11:12
 * @description: 发送post请求
 * @param {string}url
 * @param {object}data
 * @param {object}config
 */
export function httpPost(url: string, data?: {data: any}, config?: AxiosRequestConfig<{data: any}>): Promise<void | AxiosResponse<any, any>>{
    return axios.post(url, data, config).catch(error => {
        console.error(`post请求${url}时发生错误`, error.message)
    })
}
